package xyz.zdsoft.scoring_module.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.common.entity.WorkSubmitInfo;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.scoring_module.bo.ScoresBo;
import xyz.zdsoft.scoring_module.service.Impl.AdminScoreServiceImpl;
import xyz.zdsoft.scoring_module.vo.AdminHomeworkVo;
import xyz.zdsoft.scoring_module.vo.AdminPersonScoreVo;
import xyz.zdsoft.scoring_module.vo.AdminTeamScoreVo;
import xyz.zdsoft.scoring_module.vo.TrainTeacherAndTeamMemberVo;

import javax.annotation.Resource;

/**
 * 管理员-综合打分记录
 * @author 以风
 */
@Api(tags = "管理员-综合打分记录")
@RestController
@RequestMapping("/api/admin/adminScore")
public class AdminScoreController {
    @Resource
    private AdminScoreServiceImpl adminScoreService;

    @ApiOperation(value = "获取个人评分（分页、查询、重置）")
    @PostMapping("/getPersonScorePage")
    public Result<IPage<AdminPersonScoreVo>> getPersonScorePage(ScoresBo scoresBo){
        IPage<ScoresBo> page = new Page<>(scoresBo.getCurrent(),scoresBo.getSize());
        IPage<AdminPersonScoreVo> personScoreVoIPage  = adminScoreService.getPersonScorePage(page,scoresBo);
        return Result.ok().message("获取个人评分（分页、查询、重置）").data(personScoreVoIPage);
    }

    @ApiOperation(value = "个人评分-查看详情-获取实训老师")
    @GetMapping("/getTrainTeacher")
    @ApiImplicitParam(name = "courseId",value = "课程id",required = true)
    public Result getTrainTeacher(Integer courseId){
        String trainTeacher = adminScoreService.getTrainTeacher(courseId);
        return Result.ok().message("获取实训老师成功").data(trainTeacher);
    }

    @ApiOperation(value = "个人评分-查看详情-获取学生作业信息")
    @GetMapping("/getStudentHomeWork")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "studentId",value = "学生id",required = true),
            @ApiImplicitParam(name = "courseId",value = "课程id",required = true),
            @ApiImplicitParam(name = "current",value = "当前页",required = true),
            @ApiImplicitParam(name = "size",value = "当前页size",required = true)
    })
    public Result<IPage<AdminHomeworkVo>> getStudentHomeWork(Integer courseId,Integer studentId,Integer current,Integer size){
        IPage<AdminHomeworkVo> page = new Page<>(current,size);
        IPage<AdminHomeworkVo> homeworkVoIPage = adminScoreService.getStudentHomeWork(page,courseId,studentId);
        return Result.ok().message("获取学生作业信息成功").data(homeworkVoIPage);
    }

    @ApiOperation(value = "获取小组评分（分页、查询、重置）")
    @PostMapping("/getTeamScorePage")
    public Result<IPage<AdminTeamScoreVo>> getTeamScorePage(ScoresBo scoresBo){
        IPage<ScoresBo> page = new Page<>(scoresBo.getCurrent(),scoresBo.getSize());
        IPage<AdminTeamScoreVo> teamScoreVoIPage = adminScoreService.getTeamScorePage(page,scoresBo);
        return Result.ok().message("获取小组评分（分页、查询、重置）").data(teamScoreVoIPage);
    }

    @ApiOperation(value = "小组评分-查看详情-获取实训老师和小组成员")
    @GetMapping("/getTrainTeachersAndTeamMembers")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "courseId",value = "课程id",required = true),
            @ApiImplicitParam(name = "teamId",value = "小组id",required = true)
    })
    public Result getTrainTeachersAndTeamMembers(Integer courseId,Integer teamId){
        TrainTeacherAndTeamMemberVo trainTeacherAndTeamMemberVo = adminScoreService.getTrainTeachersAndTeamMembers(courseId,teamId);
        return Result.ok().message("获取实训老师和小组成员成功").data(trainTeacherAndTeamMemberVo);
    }

    @ApiOperation(value = "小组评分-查看详情-获取小组作业信息")
    @GetMapping("/getTeamHomeWork")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teamId",value = "小组id",required = true),
            @ApiImplicitParam(name = "courseId",value = "课程id",required = true),
            @ApiImplicitParam(name = "current",value = "当前页",required = true),
            @ApiImplicitParam(name = "size",value = "当前页size",required = true)
    })
    public Result<IPage<AdminHomeworkVo>> getTeamHomeWork(Integer courseId,Integer teamId,Integer current,Integer size){
        IPage<AdminHomeworkVo> page = new Page<>(current,size);
        IPage<AdminHomeworkVo> homeworkVoIPage = adminScoreService.getTeamHomeWork(page,courseId,teamId);
        return Result.ok().message("获取小组作业信息成功").data(homeworkVoIPage);
    }

    @ApiOperation(value = "查看作业详情")
    @GetMapping("/getHomeworkDetails")
    @ApiImplicitParam(name = "homeworkDetailsId",value = "作业详情id",required = true)
    public Result<WorkSubmitInfo> getHomeworkDetails(Long homeworkDetailsId){
        WorkSubmitInfo workSubmitInfo =  adminScoreService.getHomeworkDetails(homeworkDetailsId);
        return Result.ok().message("查看作业详情成功").data(workSubmitInfo);
    }


}
